﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="AssoZone.MainPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AssoZone"
    xmlns:common="using:AssoZone.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">AssoZone</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="60" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock Text="News" Grid.Column="0" Grid.Row="1" Style="{StaticResource GroupHeaderTextStyle }" Margin="140,10,0,0" />
        <TextBlock Text="Associations" Grid.Column="1" Grid.Row="1" Style="{StaticResource GroupHeaderTextStyle}" Margin="60,10,0,0" />
        <TextBlock Text="V" Grid.Column="0" Grid.Row="2" FontSize="200" Margin="80,620,0,0" Opacity="0.2" />

        <ListView Name="MyGridView" 
                  Grid.Row="2"
                  SelectionMode="None"
                  IsItemClickEnabled="True"
                  ItemClick="MyGridView_OnItemClick"
                  Margin="170,0,0,60"
                  ScrollViewer.VerticalScrollBarVisibility="Hidden"
                  
                  
                  >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid Height="250" Width="400">
                        <Image Source="{Binding ImageUrl}"></Image>
                        <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" 
                                    Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}" >
                            <TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}"
                                       Style="{StaticResource TitleTextStyle}" Margin="5,0,5,0" Height="20" />
                            <TextBlock Text="{Binding Description}" Foreground="{StaticResource CheckBoxPressedBorderThemeBrush}" 
                                       Style="{StaticResource SubtitleTextStyle}" Margin="15,0,5,0" Height="24" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>


        <GridView Name="MyGridView2" 
                  Grid.Row="2"
                  Grid.Column="1"
                  SelectionMode="None"
                  IsItemClickEnabled="True"
                  ItemClick="MyGridView_OnItemClick"
                  Margin="160,0,0,0">
            <GridView.ItemTemplate>
                <DataTemplate>
                    <Grid Height="200" Width="200">
                        <Image Source="{Binding ImageUrl2}"></Image>
                        <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" 
                                    Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}" >
                            <TextBlock Text="{Binding Name}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}"
                                       Style="{StaticResource TitleTextStyle}" Margin="10,0,20,5" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>





        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        
        


        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
    
    <Page.BottomAppBar>
    <AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
        <Grid>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                <Button Style="{StaticResource AddAppBarButtonStyle}" Click="Ajout_Asso" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Style="{StaticResource RefreshAppBarButtonStyle}" />
            </StackPanel>
        </Grid>
    </AppBar>
</Page.BottomAppBar>
    
</common:LayoutAwarePage>
